package com.jiuqi.lr_demo.dao;

import com.jiuqi.lr_demo.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserDao {
    //查询所有用户信息
    @Select("select * from restuser")
    List<User> getAllUsers();

    //根据id查询用户信息
    @Select("select * from restuser where id = #{id}")
    User getUserById(int id);

    //根据username查询用户信息
    @Select("select * from restuser where username = #{username}")
    User getUserByUsername(String username);

    //添加用户信息
    @Insert("insert into restuser(username, password) values(#{username}, #{password})")
    boolean addUser(User user);


    //更新用户信息
    @Update("update restuser set username = #{username},password = #{password} where id = #{id}")
    boolean updateUser(User user);

    //删除用户信息
    @Delete("delete from restuser where id = #{id}")
    boolean deleteUser(int id);

}
